function showInput(obj) {
	$(obj).hide();
	$(obj).next("input").show();
}

function updateClass(id, opType, obj, type) {
	var value = $(obj).val();
	if (value == '') {
		alert("不能为空!");
		return;
	}
	if (opType == '2' || opType == '3') {
		if (value != '1' && value != '0') {
			alert("必须填写0或者1");
			return;
		}
	}
	if(opType != '2' && opType != '3' && opType != '1' ){
		if(!isNaN(value)){
			return;
		}
	}
	var param = {
		"id" : id,
		"type" : opType,
		"value" : value
	}
	API.managementUpdateCompany(param, function(res) {
		if (res.code == '0') {
			window.location.reload();
		} else {
			alert(res.desc);
		}
	});
}

function deleteById(id) {
	var param = {
		"id" : id
	}
	API.managementDeleteCompany(param, function(res) {
		if (res.code == '0') {
			window.location.reload();
		} else {
			alert(res.desc);
		}
	});
}
function checkNum(obj) {
	var reg = /^[0-9]*$/;
	return reg.test(obj);

};
function addLabel(obj) {
	var name = $("#name").val();
	var type = $("#type").val();
	var contractFlag = $("#contractFlag").val();
	if (name == '' || type == '' || contractFlag == '') {
		alter("都必须填写");
		return;
	}
	if (type != '1' && type != '0'
			|| (contractFlag != '1' && contractFlag != '0')) {
		alert("类型和是否签合同必须填写0或者1");
		return;
	}
	var param = {
		"name" : name,
		"type" : type,
		"contractFlag" : contractFlag
	}
	API.managementAddCompany(param, function(res) {
		if (res.code == '0') {
			window.location.reload();
		} else {
			alert(res.desc);
		}
	});

}


function isNaN(nubmer){
	var re = new RegExp("^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$");
	if (!re.test(nubmer)) {
　　　　alert("请输入数字");
　　　　return false;
	}
	return true;
}